public class Node {
    private Node right;
    private Item key;
    private Node parent;
    private Node left;
    
    public Node() {
	left = null;
	right = null;
	parent = null;
    }
    
    public Node (Item k) {
	key = k;
	left = null;
	right = null;
	parent = null;
    }
    
    public Node (Item k, Node l, Node r) {
	key = k;
	left = l;
	right = r;
    }

    public void setLeft (Node lnode) {
	left = lnode;
    }
    
    public void setRight (Node rnode) {
	right = rnode;
    }
    
    public void setParent (Node pnode) {
	parent = pnode;
    }
    
    public void setKey (Item keyitem) {
	key = keyitem;
    }
    
    public Node getLeft () {
	return left;
    }
    
    public Node getRight () {
	return right;
    }

    public Node getParent () {
	return parent;
    }
    
    public Item getKey () {
	return key;
    }
    
    public boolean isTheSameNode (Node nodeToCompare) {
	Item comparedKey = nodeToCompare.getKey();
	int ntype = comparedKey.getNodeType();
	int keytype = key.getNodeType();
	Node cparent, cleft, cright;
	
	if(ntype == keytype)
	    {
		if(keytype == 0)
		    {
			if(comparedKey.getRandom() == key.getRandom())
			    {
				return true;
			    }
			else
			    {
				return false;
			    }
		    }
		else if(keytype == 1)
		    {
			if(comparedKey.getX() == key.getX())
			    {
				return true;
			    }
			else
			    {
				return false;
			    }
		    }
		else if(keytype == 2)
		    {
			if(comparedKey.getOperator() == key.getOperator())
			    {
				return true;
			    }
			else
			    {
				return false;
			    }
			}
		else
		    {
			System.out.println("ERROR: The item does not exist.");
			return false;
		    }
		
		}
	else
		{
		    return false;
		}
    }
    
}
